<?php
class PacientesController extends Zend_Controller_Action
{
	/**
	 * Method indexAction
	 */
	public function indexAction()
	{
		/*
		$mapper = new Application_Model_PacientesMapper();
		$data = $mapper->fetchAll();
		var_dump($data);
		*/
	}

	/**
	 * Method searchAction
	 */
	public function searchAction()
	{
		$this->_helper->layout->disableLayout();
		$this->_helper->viewRenderer('list');

		if ($this->_request->isXmlHttpRequest()) {
			$this->view->cadena = $cadena = $this->_request->getParam('busqueda');
			$mapper = new Application_Model_PacientesMapper();
			$result = $mapper->search($cadena);
			if (count($result)) {
				$this->view->data = $result;
			} else {
				$this->view->data = array();
			}
		} else {
			throw new Exception('Peticion sin ajax');
		}
	}

}
